<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" :rules="rules" label-width="150px">
      <el-form-item label="客服微信号配置" prop="configValue">
        <el-input v-model="queryParams.configValue" placeholder="请输入客服微信号配置" clearable />
      </el-form-item>
    </el-form>
    <el-button type="primary" plain size="mini" @click="submitForm">保存提交</el-button>
  </div>
</template>

<script>
import { listConfig, getConfig, addConfig, updateConfigWxConfig } from "@/api/system/config";
export default {
  name: "operationConfiguration",
  data() {
    return {
      queryParams: {
        configValue: undefined,
      },
      rules: {
        configValue: [
          { required: true, message: "客服微信号配置不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      getConfig(6).then(res => {
        if (res.code == 200) {
          this.queryParams.configValue = res.data.configValue;
          this.queryParams.configId = res.data.configId;

        }
      })
    },
    /** 提交按钮 */
    submitForm() {
      if (this.queryParams.configId != undefined) {
        updateConfigWxConfig(this.queryParams).then(res => {
          if (res.code == 200) {
            this.$modal.msgSuccess("操作成功");
          }
        })
      } else {
        addConfig(this.queryParams).then(res => {
          if (res.code == 200) {
            this.$modal.msgSuccess("操作成功");
          }
        })
      }
    },
  },
};
</script>
